package com.sciencep.pro.admin;

import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.embedded.tomcat.TomcatConnectorCustomizer;
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;

import javax.annotation.PostConstruct;
import java.util.TimeZone;

@SpringBootApplication
@MapperScan({"com.sciencep.pro.admin.system.dao","com.sciencep.pro.core.dao"})
@ComponentScan({"com.sciencep.pro.admin.*","com.sciencep.pro.core.*","com.sciencep.pro.common.*"})
public class OscaAdminApplication {

    public static void main(String[] args) {
        SpringApplication.run(OscaAdminApplication.class, args);
    }

    @Bean
    public TomcatServletWebServerFactory tomcatServletWebServerFactory(){
        // 修改内置的 tomcat 容器配置
        TomcatServletWebServerFactory tomcatServlet=new TomcatServletWebServerFactory();
        tomcatServlet.addConnectorCustomizers(
                (TomcatConnectorCustomizer) connector->connector.setProperty("relaxedQueryChars","[]{}")
        );

        return tomcatServlet;
    }

    @PostConstruct
    void started() {
        TimeZone.setDefault(TimeZone.getTimeZone("Asia/Shanghai"));
    }
}
